import React,{Component} from 'react';
import {Form,Input,Select} from 'antd'

class DataForm extends Component {

    componentDidMount(){
        this.props.onRef(this.formRef.current);
    }
    formRef = React.createRef();

    render(){
        const { initialData} = this.props
        console.log('in form', initialData)
        const validateMessages = {
            required: "请输入",
          };
        const rules={ required: true };
        const style={color:'rgb(0,126,220)',fontWeight:'bold'};
        return(
            <Form ref={this.formRef} labelCol={{span:24}} initialValues={this.props.initialData} wrapperCol={{span:20}} validateMessages={validateMessages}>
                <Form.Item style={{marginBottom: '10px'}} required label={<span style={style}>上级类型</span>}>
                    <span>{initialData.upType}</span>
                </Form.Item>
                <Form.Item style={{marginBottom: '10px'}} required label={<span style={style}>类型</span>}>
                    <span>{initialData.curType}</span>
                </Form.Item>
                <Form.Item style={{marginBottom: '10px'}} rules={[rules]} label={<span style={style}>名称</span>} name='name'>
                    <Input placeholder='请输入中文名称'/>
                </Form.Item>
                <Form.Item style={{marginBottom: '10px'}} required label={<span style={style}>上级编码</span>}>
                    <span>{initialData.superNumber}</span>
                </Form.Item>
                <Form.Item style={{marginBottom: '10px'}} label={<span style={style}>编码</span>} name='number'>
                    <span>{initialData.curNumber}</span>
                    {/* <Input placeholder='请输入编码'/> */}
                </Form.Item>
                {
                    this.props.departMentShow && 
                    <Form.Item style={{marginBottom: '10px'}} label={<span style={style}>所属部门</span>} name='department'>
                        <span>{initialData.departMent}</span>
                    </Form.Item>
                }
                {/* <Form.Item style={{marginBottom: '10px'}} label={<span style={style}>所属部门</span>} name='department'>
                    <span>{initialData.departMent}</span>
                </Form.Item> */}
                <Form.Item rules={[rules]} label={<span style={style}>备注</span>} name='description'>
                    <Input placeholder='请输入备注'/>
                </Form.Item>
            </Form>
        )
    }
}

export default DataForm;